<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>服务创建--layui后台管理模板 2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form" style="width:80%;" lay-filter="dataFrm" id="dataFrm" >
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">客户:</label>
        <div class="layui-input-block">
            <select id="custkh" name="client" class="custGrade" lay-filter="custkh" style="width: 600px">

            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">服务类型:</label>
        <div class="layui-input-block">
            <select id="basicTypekh" name="type" class="basicTypeGrade" lay-filter="basicTypekh" style="width: 600px">

            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">创建人：</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input founder" lay-verify="required" name="founder"  style="width: 100px">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">状态:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input conditions" name="conditions" lay-verify="required" value="新创建"  readonly="readonly" style="width: 100px">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label" >概要:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input outline" lay-verify="required" name="outline" style="width: 600px">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">创建时间:</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input creatTime" lay-verify="required" name="creatTime" placeholder="请确定当前时间" id="creatTime" style="width: 200px">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">服务请求:</label>
        <div class="layui-input-block">
            <textarea cols="80" rows="10 " name="request"></textarea>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addService">提交</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">关于</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>
<script th:inline="none">
    var html = "";
    layui.use(['form','layer','table','laytpl','laydate','upload'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery,
            laytpl = layui.laytpl,
            table = layui.table,
            laydate=layui.laydate,
            upload = layui.upload;
        //动态绑定下拉菜单的数据
        $.ajax({
            url:'custs1.do',
            success:function (data) {
                html="";
                html += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html += ("<option value='" + data[i].cust_name + "'>" + data[i].cust_name + "</option>")
                }
                $("#custkh").append(html);
                form.render('select');
            }
        });
        $.ajax({
            url:'basicTypes.do',
            success:function (data) {
                html="";
                html += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html += ("<option value='" + data[i].basiType_item + "'>" + data[i].basiType_item + "</option>")
                }
                $("#basicTypekh").html(html);
                form.render('select');
            }
        });

        layui.use('laydate', function() {
            var laydate = layui.laydate;
            var now = new Date();
            laydate.render({
                elem: '#creatTime',
                theme: 'molv',
                format:'yyyy-MM-dd HH:mm:ss',
                type: 'datetime',
                trigger: 'click',
                max:4073558400000, //公元3000年1月1日
                ready: function(date){
                    //console.log(date); //得到初始的日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
                    this.dateTime.hours=now.getHours();
                    this.dateTime.minutes=now.getMinutes();
                    this.dateTime.seconds=now.getSeconds();
                }

            });
        });

        //增加用户
        form.on("submit(addService)", function (data) {
            var index = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.4});
            //实际使用时的提交数据
            var params = $("#dataFrm").serialize();
            console.log(params);
            $.post("service/insertservice.do", params, function (res) {
                console.log(res)
                if (res.code == 200) {
                    setTimeout(function () {
                        top.layer.close(index);
                        top.layer.msg("添加成功！");
                        //刷新父页面
                        parent.location.reload();
                    }, 2000)
                }
            }, "json");
            return false;
        });

    })
</script>

</body>
</html></html>